<?php

/**
 * PhpFlix_Netflix_User
 * 
 * @author Richard Hoppes <rhoppes@gmail.com>
 */
class PhpFlix_Netflix_User extends PhpFlix_Netflix 
{	
	
	/**
	 * requestToken
	 * 
	 * @return string result
	 * @author Richard Hoppes <rhoppes@gmail.com>
	 * 
	 */
	public function requestToken()
	{
		$strRequestUrl = $this->getOAuthGetUrl(NETFLIX_API_OAUTH_REQUEST_TOKEN);
		
		return $this->getResource($strRequestUrl);
	}
	
	
	/**
	 * getAuthorizationUrl
	 * 
	 * @param string $strURL authorization url
	 * @param string $strApplicationName application name
	 * @param string $strOAuthToken token
	 * @param string $strOAuthTokenSecret token secret
	 * @param string $strCallbackURL url that user will be directed to once they are authorized
	 * @return string OAUTH authorization url
	 * @author Richard Hoppes <rhoppes@gmail.com>
	 */
	public function getAuthorizationUrl($strUrl, $strApplicationName, $strOAuthToken, $strOAuthTokenSecret)
	{	
		$arrParameters = array('application_name' => $strApplicationName);
		
		if($this->_strLoginCallback)
			$arrParameters['oauth_callback'] = $this->_strLoginCallback;
		
		return $this->getOAuthGetUrl($strUrl, $arrParameters, $strOAuthToken, $strOAuthTokenSecret);
	}	
	
	
	/**
	 * requestAccessToken
	 * 
	 * @param string $strOAuthToken token
	 * @param string $strOAuthTokenSecret token secret
	 * @return array parsed result
	 * @author Richard Hoppes <rhoppes@gmail.com>
	 */
	public function requestAccessToken($strOAuthToken, $strOAuthTokenSecret) 
	{
		$strRequestUrl = $this->getOAuthGetUrl(NETFLIX_API_OAUTH_ACCESS_TOKEN, array(), $strOAuthToken, $strOAuthTokenSecret);
		
		return $this->getResource($strRequestUrl);
	}
	
	
	/**
	 * getUserData
	 *
	 * @author Richard Hoppes <rhoppes@gmail.com>
	 */
	public function getData($strUserAccessToken, $strOAuthToken, $strOAuthTokenSecret) 
	{
		$strUrl = NETFLIX_API_USERS . "/" . $strUserAccessToken;
		
		$strRequestUrl = $this->getOAuthGetUrl($strUrl, array(), $strOAuthToken, $strOAuthTokenSecret);
		
		return $this->getResource($strRequestUrl);
	}
	
}